import { createWebHashHistory, createRouter } from 'vue-router';
import menuRoutes from './menus';

export const routes = [
    {
        path: '/:pathMatch(.*)*',
        redirect: '/404',
    },
    {
        path: '/404',
        component: () => import('@/views/404'),
    },
    {
        path: '/',
        redirect: (menuRoutes[0] || {}).path || (((menuRoutes[0] || {}).children || [])[0] || {}).path || '',
        component: () => import('@/views/master'),
        children: menuRoutes,
        meta: {},
    },
];

const router = createRouter({
    history: createWebHashHistory(),
    routes,
    scrollBehavior: (to, from, savedPosition) => savedPosition || { top: 0 },
});

export default router;
